home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue37 / outlook / mapi / mapiform.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-06-18  |  16.0 KB  |  473 lines

  1. {++
  2.  
  3.   m a p i f o r m . p a s
  4.  
  5.   Abstract:
  6.  
  7.     Automatic conversion of mapiform.h.
  8.  
  9.   Comments:
  10.  
  11.     This source file automatically converted by
  12.     htrans 0.91 beta 1 Copyright (c) 1997 Alexander Staubo
  13.  
  14.   Revision history:
  15.  
  16.     18-06-1997 20:53 alex  [Autogenerated]
  17.     18-06-1997 20:53 alex  Retouched for release
  18.  
  19. --}
  20.  
  21. unit MapiForm;
  22.  
  23. {$A+}
  24. {$MINENUMSIZE 4}
  25.  
  26. interface
  27.  
  28. uses
  29.   Windows, SysUtils, ActiveX,
  30.   MapiGuid, MapiDefs, MapiX;
  31.  
  32. (*
  33.  *  M A P I F O R M . H
  34.  *
  35.  *  Declarations of interfaces for clients and providers of MAPI
  36.  *  forms and form registries.
  37.  *
  38.  *  Copyright 1986-1996 Microsoft Corporation. All Rights Reserved.
  39.  *)
  40.  
  41. type
  42.   PCRECT = ^TRECT;
  43.  
  44. (* HFRMREG is an enumeration which represents a registry container.
  45.  * Microsoft reserves the values from 0 to 0x3FFF for its own use.
  46.  *)
  47.  
  48.   THFRMREG = ULONG;
  49.   
  50. const
  51.   HFRMREG_DEFAULT = 0;
  52.   HFRMREG_LOCAL = 1;
  53.   HFRMREG_PERSONAL = 2;
  54.   HFRMREG_FOLDER = 3;
  55.  
  56. type
  57.   PPCSTR = ^PChar;
  58.  
  59.   TSAVEOPTS =
  60.     (
  61.       SAVEOPTS_SAVEIFDIRTY,
  62.       SAVEOPTS_NOSAVE,
  63.       SAVEOPTS_PROMPTSAVE
  64.     );
  65.  
  66. (* Implemented by viewers to support next/previous in forms.
  67.  *)
  68.  
  69. { Structure passed in GetPrintSetup  }
  70.  
  71. type
  72.   TFORMPRINTSETUP =     
  73.     record
  74.       ulFlags : ULONG;                 { MAPI_UNICODE }
  75.       hDevMode : HGLOBAL;
  76.       hDevNames : HGLOBAL;
  77.       ulFirstPageNumber : ULONG;
  78.       fPrintAttachments : ULONG;
  79.     end;
  80.  
  81.   PFORMPRINTSETUP = ^TFORMPRINTSETUP;
  82.  
  83. { Values for pulFormat in GetSaveStream }
  84.  
  85. type
  86.   TFORMPROPSPECIALTYPE = ULONG;
  87.  
  88. const
  89.   SAVE_FORMAT_TEXT = 1;
  90.   SAVE_FORMAT_RICHTEXT = 2;
  91.  
  92.   { Values from 0 to 0x3fff are reserved for future definition by Microsoft }
  93.  
  94. const
  95.   VCSTATUS_NEXT = $00000001;
  96.   VCSTATUS_PREV = $00000002;
  97.   VCSTATUS_MODAL = $00000004;
  98.   VCSTATUS_INTERACTIVE = $00000008;
  99.   VCSTATUS_READONLY = $00000010;
  100.   VCSTATUS_DELETE = $00010000;
  101.   VCSTATUS_COPY = $00020000;
  102.   VCSTATUS_MOVE = $00040000;
  103.   VCSTATUS_SUBMIT = $00080000;
  104.   VCSTATUS_DELETE_IS_MOVE = $00100000;
  105.   VCSTATUS_SAVE = $00200000;
  106.   VCSTATUS_NEW_MESSAGE = $00400000;
  107.   VCDIR_NEXT = VCSTATUS_NEXT;
  108.   VCDIR_PREV = VCSTATUS_PREV;
  109.   VCDIR_DELETE = VCSTATUS_DELETE;
  110.   VCDIR_MOVE = VCSTATUS_MOVE;
  111.  
  112. { MAPI Form property descriptor }
  113.  
  114. (*
  115.  * Values for the tag in the SMAPIFormProp structure
  116.  *
  117.  * Microsoft reserves the range from 0 to 0x3FFF for future use in its other
  118.  * forms registry implementations.
  119.  *)
  120.  
  121.   FPST_VANILLA = 0;
  122.   FPST_ENUM_PROP = 1;
  123.  
  124. { Enumeration of permissible values for PR_FORM_MESSAGE_BEHAVIOR }
  125.  
  126.   MAPI_MESSAGE_BEHAVIOR_IPM = 0;
  127.   MAPI_MESSAGE_BEHAVIOR_FOLDER = 1;
  128.  
  129. { Platform numbers (used in .CFG files for forms) }
  130.  
  131. const
  132.   MAPIFORM_CPU_X86 = 1;
  133.   MAPIFORM_CPU_MIP = 2;
  134.   MAPIFORM_CPU_AXP = 3;
  135.   MAPIFORM_CPU_PPC = 4;
  136.   MAPIFORM_CPU_M68 = 5;
  137.   MAPIFORM_OS_WIN_31 = 1;
  138.   MAPIFORM_OS_WINNT_35 = 2;
  139.   MAPIFORM_OS_WIN_95 = 3;
  140.   MAPIFORM_OS_MAC_7x = 4;
  141.   MAPIFORM_OS_WINNT_40 = 5;
  142.  
  143. {  Flags for IMAPIFormMgr::CalcFormPropSet }
  144.  
  145. { #define FORMPROPSET_UNION            0   }
  146.  
  147. { #define FORMPROPSET_INTERSECTION     1   }
  148.  
  149. {  Flags for IMAPIFormMgr::InstallForm     }
  150.  
  151.   MAPIFORM_INSTALL_DIALOG = MAPI_DIALOG;
  152.   MAPIFORM_INSTALL_OVERWRITEONCONFLICT = $0010;
  153.  
  154. {  Flags for IMAPIFormContainer::ResolveMessageClass and
  155.       IMAPIFormContainer::ResolveMultipleMessageClasses }
  156.  
  157. { #define MAPIFORM_EXACTIMATCH    0x0020   }
  158.  
  159. {!! Interface forwards }
  160.  
  161. type
  162.   IMAPIMessageSite = interface;
  163.   IMAPIFormInfo = interface;
  164.   IMAPIFormMgr = interface;
  165.   IMAPIViewContext = interface;
  166.   IMAPIViewAdviseSink = interface;
  167.   IMAPIFormAdviseSink = interface;
  168.   IMAPIFormContainer = interface;
  169.  
  170. { Single enum value }
  171.  
  172.   TSMAPIFormPropEnumVal =
  173.     record                             { fpev }
  174.       pszDisplayName : PChar;          { carries the display string }
  175.       nVal : ULONG;                    { the value for the above enumeration }
  176.     end;
  177.  
  178.   PMAPIFORMPROPENUMVAL = ^TSMAPIFormPropEnumVal;
  179.  
  180.   TSMAPIFormProp =
  181.     record
  182.       ulFlags : ULONG;                 { Contains MAPI_UNICODE if strings are UNICODE }
  183.       nPropType : ULONG;               { type of the property, hiword is 0 }
  184.       nmid : TMAPINAMEID;              { id of the property }
  185.       pszDisplayName : PChar;
  186.       nSpecialType : TFORMPROPSPECIALTYPE;
  187.                                        { tag for the following union }
  188.       u :
  189.         record
  190.           case Integer of
  191.             1 :
  192.               (
  193.                 s1 : { Property String/Number association Enumeration }
  194.                   record
  195.                     nmidIdx : TMAPINAMEID;
  196.                     cfpevAvailable : ULONG; { # of enums }
  197.                     pfpevAvailable : PMAPIFORMPROPENUMVAL;
  198.                   end;
  199.               );
  200.         end;
  201.     end;
  202.  
  203.   PMAPIFORMPROP = ^TSMAPIFormProp;
  204.  
  205. { Array of form properties }
  206.  
  207.   TSMAPIFormPropArray =
  208.     record
  209.       cProps : ULONG;
  210.       ulPad : ULONG;                   { Pad to 8-byte alignment for insurance }
  211.       aFormProp : array[0..MAPI_DIM - 1] of TSMAPIFormProp;
  212.     end;
  213.  
  214.   PMAPIFORMPROPARRAY = ^TSMAPIFormPropArray;
  215.  
  216. { Structure defining the layout of an mapi verb description }
  217.  
  218.   TSMAPIVerb =
  219.     record
  220.       lVerb : Longint;
  221.       szVerbname : PChar;
  222.       fuFlags : DWORD;
  223.       grfAttribs : DWORD;
  224.       ulFlags : ULONG;                 { Either 0 or MAPI_UNICODE }
  225.     end;
  226.  
  227.   PMAPIVERB = ^TSMAPIVerb;
  228.  
  229. { Structure used for returning arrays of mapi verbs }
  230.  
  231.   TSMAPIVerbArray =
  232.     record
  233.       cMAPIVerb : ULONG;               { Number of verbs in the structure }
  234.       aMAPIVerb : array[0..MAPI_DIM - 1] of TSMAPIVerb;
  235.     end;
  236.  
  237.   PMAPIVERBARRAY = ^TSMAPIVerbArray;
  238.  
  239. { Structure containing an array of message class strings }
  240.  
  241.   TSMessageClassArray =
  242.     record
  243.       cValues : ULONG;
  244.       aMessageClass : array[0..MAPI_DIM - 1] of LPCSTR;
  245.     end;
  246.  
  247.   PSMESSAGECLASSARRAY = ^TSMessageClassArray;
  248.  
  249. { Structure containing an array of IMAPIFormInfo interfaces }
  250.  
  251.   TSMAPIFormInfoArray =
  252.     record
  253.       cForms : ULONG;
  254.       aFormInfo : array[0..MAPI_DIM - 1] of IMAPIFormInfo;
  255.     end;
  256.  
  257.   PSMAPIFORMINFOARRAY = ^TSMAPIFormInfoArray;
  258.  
  259. (* This interface is implemented by forms and is used to save,
  260.  * initialize and load forms to and from messages.
  261.  *)
  262.  
  263.   IPersistMessage =
  264.     interface(IUnknown)
  265.     [strIID_IPersistMessage]
  266.       function GetLastError (hResult : HResult; ulFlags : ULONG;
  267.         var lppMAPIError : PMAPIERROR) : HResult; stdcall;
  268.       function GetClassID (var lpClassID : TCLSID) : HResult; stdcall;
  269.       function IsDirty : HResult; stdcall;
  270.       function InitNew (pMessageSite : IMAPIMessageSite; pMessage : IMessage) : HResult; stdcall;
  271.       function Load (pMessageSite : IMAPIMessageSite; pMessage : IMessage; 
  272.         ulMessageStatus : ULONG; ulMessageFlags : ULONG) : HResult; stdcall;
  273.       function Save (pMessage : IMessage; fSameAsLoad : ULONG) : HResult; stdcall;
  274.       function SaveCompleted (pMessage : IMessage) : HResult; stdcall;
  275.       function HandsOffMessage : HResult; stdcall;
  276.     end;
  277.  
  278.   IMAPIMessageSite =
  279.     interface(IUnknown)
  280.     [strIID_IMAPIMessageSite]
  281.       function GetLastError (hResult : HResult; ulFlags : ULONG;
  282.         var lppMAPIError : PMAPIERROR) : HResult; stdcall;
  283.       function GetSession (out ppSession : IMAPISession) : HResult; stdcall;
  284.       function GetStore (out ppStore : IMsgStore) : HResult; stdcall;
  285.       function GetFolder (out ppFolder : IMAPIFolder) : HResult; stdcall;
  286.       function GetMessage (out ppmsg : IMessage) : HResult; stdcall;
  287.       function GetFormManager (out ppFormMgr : IMAPIFormMgr) : HResult; stdcall;
  288.       function NewMessage (fComposeInFolder : ULONG; pFolderFocus : IMAPIFolder; 
  289.         pPersistMessage : IPersistMessage; out ppMessage : IMessage; 
  290.         out ppMessageSite : IMAPIMessageSite;
  291.         out ppViewContext : IMAPIViewContext) : HResult; stdcall;
  292.       function CopyMessage (pFolderDestination : IMAPIFolder) : HResult; stdcall;
  293.       function MoveMessage (pFolderDestination : IMAPIFolder; 
  294.         pViewContext : IMAPIViewContext; prcPosRect : PCRECT) : HResult; stdcall;
  295.       function DeleteMessage (pViewContext : IMAPIViewContext;
  296.         prcPosRect : PCRECT) : HResult; stdcall;
  297.       function SaveMessage : HResult; stdcall;
  298.       function SubmitMessage (ulFlags : ULONG) : HResult; stdcall;
  299.       function GetSiteStatus (lpulStatus : PULONG) : HResult; stdcall;
  300.     end;
  301.  
  302. (* This interface is implemented by forms for the benefit of viewers.
  303.  * One method (ShutdownForm) is provided such that simple forms implementing
  304.  * only IMAPIForm and IPersistMessage have reasonable embedding behavior.
  305.  *)
  306.  
  307.   IMAPIForm =
  308.     interface(IUnknown)
  309.     [strIID_IMAPIForm]
  310.       function GetLastError (hResult : HResult; ulFlags : ULONG;
  311.         var lppMAPIError : PMAPIERROR) : HResult; stdcall;
  312.       function SetViewContext (
  313.         pViewContext : IMAPIViewContext) : HResult; stdcall;
  314.       function GetViewContext (
  315.         out ppViewContext : IMAPIViewContext) : HResult; stdcall;
  316.       function ShutdownForm (ulSaveOptions : ULONG) : HResult; stdcall;
  317.       function DoVerb (iVerb : Longint; lpViewContext : IMAPIViewContext; { can be null }
  318.         hwndParent : ULONG; lprcPosRect : PCRECT) : HResult; stdcall;
  319.       function Advise (pAdvise : IMAPIViewAdviseSink;
  320.         var pdwStatus : ULONG) : HResult; stdcall;
  321.       function Unadvise (ulConnection : ULONG) : HResult; stdcall;
  322.     end;
  323.  
  324.   IMAPIViewContext =
  325.     interface(IUnknown)
  326.     [strIID_IMAPIViewContext]
  327.       function GetLastError (hResult : HResult; ulFlags : ULONG;
  328.         var lppMAPIError : PMAPIERROR) : HResult; stdcall;
  329.       function SetAdviseSink (pmvns : IMAPIFormAdviseSink) : HResult; stdcall;
  330.       function ActivateNext (ulDir : ULONG;
  331.         prcPosRect : PCRECT) : HResult; stdcall;
  332.       function GetPrintSetup (ulFlags : ULONG;
  333.         var lppFormPrintSetup : PFORMPRINTSETUP) : HResult; stdcall;
  334.       function GetSaveStream (var pulFlags : ULONG; var pulFormat : ULONG;
  335.         out ppstm : IStream) : HResult; stdcall;
  336.       function GetViewStatus (lpulStatus : PULONG) : HResult; stdcall;
  337.     end;
  338.  
  339. (* Part of form server, held by view; receives notifications from the view.
  340.  *
  341.  * This part of the form server, but is not an interface on the form
  342.  * object.  This means that clients should not expect to QueryInterface
  343.  * from an IMAPIForm* or IOleObject* to this interface, or vice versa.
  344.  *)
  345.  
  346.   IMAPIFormAdviseSink =
  347.     interface(IUnknown)
  348.     [strIID_IMAPIFormAdviseSink]
  349.       function OnChange (ulDir : ULONG) : HResult; stdcall;
  350.       function OnActivateNext (lpszMessageClass : LPCSTR;
  351.         ulMessageStatus : ULONG; ulMessageFlags : ULONG;
  352.         out ppPersistMessage : IPersistMessage) : HResult; stdcall;
  353.     end;
  354.  
  355. (* Part of view context, held by form; receives notifications from the form.
  356.  *)
  357.  
  358.   IMAPIViewAdviseSink =
  359.     interface(IUnknown)
  360.     [strIID_IMAPIViewAdviseSink]
  361.       function OnShutdown : HResult; stdcall;
  362.       function OnNewMessage : HResult; stdcall;
  363.       function OnPrint (dwPageNumber : ULONG;
  364.         hrStatus : HResult) : HResult; stdcall;
  365.       function OnSubmitted : HResult; stdcall;
  366.       function OnSaved : HResult; stdcall;
  367.     end;
  368.  
  369. (* Is implemented by registries.  Describes the form.
  370.  *)
  371.  
  372.   PMAPIFormInfo = ^IMAPIFormInfo;
  373.   IMAPIFormInfo =
  374.     interface(IMAPIProp)
  375.     [strIID_IMAPIFormInfo]
  376.       { note: subsumes getlasterror }
  377.       function CalcFormPropSet (ulFlags : ULONG;
  378.         var ppFormPropArray : PMAPIFORMPROPARRAY) : HResult; stdcall;
  379.       function CalcVerbSet (ulFlags : ULONG;
  380.         var ppMAPIVerbArray : PMAPIVERBARRAY) : HResult; stdcall;
  381.       function MakeIconFromBinary (nPropID : ULONG;
  382.         var phicon : HICON) : HResult; stdcall;
  383.       function SaveForm (szFileName : PChar) : HResult; stdcall;
  384.       function OpenFormContainer (
  385.         out ppformcontainer : IMAPIFormContainer) : HResult; stdcall;
  386.     end;
  387.  
  388. (* The client-visible interface for form resolution and dispatch.
  389.  *)
  390.  
  391.   IMAPIFormMgr =
  392.     interface(IUnknown)
  393.     [strIID_IMAPIFormMgr]
  394.       function GetLastError (hResult : HResult; ulFlags : ULONG;
  395.         var lppMAPIError : PMAPIERROR) : HResult; stdcall;
  396.       function LoadForm (ulUIParam : ULONG; ulFlags : ULONG;
  397.         lpszMessageClass : LPCSTR; ulMessageStatus : ULONG; ulMessageFlags : ULONG;
  398.         pFolderFocus : IMAPIFolder; pMessageSite : IMAPIMessageSite;
  399.         pmsg : IMessage; pViewContext : IMAPIViewContext; riid : PIID;
  400.         out ppvObj : IUnknown) : HResult; stdcall;
  401.       function ResolveMessageClass (szMsgClass : LPCSTR; ulFlags : ULONG;
  402.         pFolderFocus : IMAPIFolder;  { can be null }
  403.         out ppResult : IMAPIFormInfo) : HResult; stdcall;
  404.       function ResolveMultipleMessageClasses (pMsgClasses : PSMESSAGECLASSARRAY;
  405.         ulFlags : ULONG; pFolderFocus : IMAPIFolder; { can be null }
  406.       var pfrminfoarray : PSMAPIFORMINFOARRAY) : HResult; stdcall;
  407.       function CalcFormPropSet (pfrminfoarray : PSMAPIFORMINFOARRAY; ulFlags : ULONG;
  408.         var ppResults : PMAPIFORMPROPARRAY) : HResult; stdcall;
  409.       function CreateForm (ulUIParam : ULONG; ulFlags : ULONG;
  410.         pfrminfoToActivate : IMAPIFormInfo; refiidToAsk : PIID;
  411.         out ppvObj : IUnknown) : HResult; stdcall;
  412.       function SelectForm (ulUIParam : ULONG; ulFlags : ULONG;
  413.         pszTitle : PChar; pfld : IMAPIFolder;
  414.         out ppfrminfoReturned : IMAPIFormInfo) : HResult; stdcall;
  415.       function SelectMultipleForms (ulUIParam : ULONG; ulFlags : ULONG;
  416.         pszTitle : PChar; pfld : IMAPIFolder; pfrminfoarray : PSMAPIFORMINFOARRAY;
  417.         var ppfrminfoarray : PSMAPIFORMINFOARRAY) : HResult; stdcall;
  418.       function SelectFormContainer (ulUIParam : ULONG; ulFlags : ULONG; 
  419.         out lppfcnt : IMAPIFormContainer) : HResult; stdcall;
  420.       function OpenFormContainer (hfrmreg : THFRMREG; lpunk : IUnknown; 
  421.         out lppfcnt : IMAPIFormContainer) : HResult; stdcall;
  422.       function PrepareForm (ulUIParam : ULONG; ulFlags : ULONG; 
  423.         pfrminfo : IMAPIFormInfo) : HResult; stdcall;
  424.       function IsInConflict (ulMessageFlags : ULONG; ulMessageStatus : ULONG; 
  425.         szMessageClass : LPCSTR; pFolderFocus : IMAPIFolder) : HResult; stdcall;
  426.     end;
  427.  
  428.   IMAPIFormContainer =
  429.     interface(IUnknown)
  430.     [strIID_IMAPIFormContainer]
  431.       function GetLastError (hResult : HResult; ulFlags : ULONG;
  432.         var lppMAPIError : PMAPIERROR) : HResult; stdcall;
  433.       function InstallForm (ulUIParam : ULONG; ulFlags : ULONG;
  434.         szCfgPathName : PChar) : HResult; stdcall;
  435.       function RemoveForm (szMessageClass : LPCSTR) : HResult; stdcall;
  436.       function ResolveMessageClass (szMessageClass : LPCSTR; ulFlags : ULONG; 
  437.         var pforminfo : IMAPIFormInfo) : HResult; stdcall;
  438.       function ResolveMultipleMessageClasses (
  439.         pMsgClassArray : PSMESSAGECLASSARRAY; ulFlags : ULONG;
  440.         var ppfrminfoarray : PSMAPIFORMINFOARRAY) : HResult; stdcall;
  441.       function CalcFormPropSet (ulFlags : ULONG;
  442.         var ppResults : PMAPIFORMPROPARRAY) : HResult; stdcall;
  443.       function GetDisplay (ulFlags : ULONG;
  444.         var pszDisplayName : PChar) : HResult; stdcall;
  445.     end;
  446.  
  447.   IMAPIFormFactory =
  448.     interface(IUnknown)
  449.     [strIID_IMAPIFormFactory]
  450.       function GetLastError (hResult : HResult; ulFlags : ULONG;
  451.         var lppMAPIError : PMAPIERROR) : HResult; stdcall;
  452.       function CreateClassFactory (const clsidForm : TIID{!! was: REFCLSID };
  453.         ulFlags : ULONG; out lppClassFactory : IClassFactory) : HResult; stdcall;
  454.       function LockServer (ulFlags : ULONG; fLockServer : ULONG) : HResult; stdcall;
  455.     end;
  456.  
  457. function MAPIOpenFormMgr (pSession : IMAPISession;
  458.   out ppmgr : IMAPIFormMgr) : HResult; stdcall;
  459.  
  460. function MAPIOpenLocalFormContainer (
  461.   out ppfcnt : IMAPIFormContainer) : HResult; stdcall;
  462.  
  463. implementation
  464.  
  465. const
  466.   Mapi32Dll = 'mapi32.dll';
  467.  
  468. function MAPIOpenFormMgr; external Mapi32Dll name 'MAPIOpenFormMgr';
  469. function MAPIOpenLocalFormContainer; external Mapi32Dll name 'MAPIOpenLocalFormContainer';
  470.  
  471. end.
  472.  
  473.